import sys
import re
import pygeoip
import time


print time.asctime()
print '\nInstituto Politecnico de Beja '
print 'Escola Superior de Tecnologia e Gestao'
print 'Mestrado em Engenharia de Seguranca Informatica'
print 'Linguagens de Programacao Dinamica\n' 





gi=pygeoip.GeoIP('GeoLiteCity.dat', pygeoip.MEMORY_CACHE)



for line in sys.stdin:
	        if not re.search ("SRC=192",line):
	                lista=line.split("SRC=")
        	        IP=lista[1].split(' ')[0]
			rec=gi.record_by_name(IP)
			
			
                try:
			city=rec['city']
        		region=rec['region_name']
        		country = rec['country_name']
        		long = rec['longitude']
        		lat = rec ['latitude']
        		print '[*] Target: ' + IP + ' Geo-located. '
        		print '[+] ' +str(city)+', '+str(region)+', '+str(country)
        		print '[+] Latitude: '+str(lat)+ ', Longitude: '+str(long)
                        
	

                except:

                        continue

  
